<template>
    <div class="cmp cmp-cyberplayer" :id="id"></div>
</template>

<script>

export default {
  name: 'cmp-cyberplayer',
  props: {
    videoUrl: {
      type: String,
      default: ''
    },
    ak: {
      type: String,
      default: ''
    }
  },
  data () {
    return {
        id: 'player_' + `${Math.random()}`.substring(2),
        cyberVideoObj: null,
    }
  },
  methods: {
    // 播放
    play () {
      this.cyberVideoObj = global.cyberplayer(this.id).setup({
        file: this.videoUrl,
        autostart: true,
        width: '100%',
        height: '100%',
        stretching: 'uniform',
        volume: 100,
        controls: true,
        playRateConfig: [{label: '×1'}, {label: '×1.25'}, {label: '×1.5'}, {label: '×1.75'}, {label: '×2'}, {label: '×2.5'}],
        ak: this.ak
      })
    },
    // 暂停
    pause () {
        this.cyberVideoObj && this.cyberVideoObj.pause()
    },
    // 销毁
    destroy () {
        this.cyberVideoObj && this.cyberVideoObj.stop()
    }
  }
}
</script>

<style scoped lang="less">
@import "~@/assets/css/_mixins.less";
@import "~@/assets/css/_color.less";
.cmp-cyberplayer {
    display: block;
    width: 100%;
    height: 100%;
    background-color: #333;
}
</style>
